package com.example.weather.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by hanjun on 2016/7/30.
 */
public class SharePreferenceManager {
    public final static String KEY_DEFAULT_CITY = "defaultCity";


    public static void setDefaultCity(Context context,String defaultCity){
        SharedPreferences share = context.getSharedPreferences("Weather",Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = share.edit(); //编辑文件
        edit.putString(KEY_DEFAULT_CITY,defaultCity);
        edit.commit();
    }

    public static String getDefaultCity(Context context){
        SharedPreferences share = context.getSharedPreferences("Weather",Context.MODE_PRIVATE);
        String defaultCity = share.getString(KEY_DEFAULT_CITY,"大连");
        return defaultCity;
    }
}
